
function qx(){

    //关闭弹框
    let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    parent.layer.close(index); //再执行关闭

    parent.refaseUser();
}

//下拉框  图片类型 进行判断
var sex = localStorage.getItem("userSex");
console.log("下拉框的值："+sex);
if(sex == 1){
    $("#userSex").val(sex);
}

layui.use(['form','laydate','form','element','upload','element'], function() {
    var form = layui.form,
        layer = layui.layer,
        upload = layui.upload,
        element = layui.element,
        laydate = layui.laydate;

    laydate.render({
        elem:'#createDate',
        type: 'date'
    })

    var item = localStorage.getItem("url");
    $('#avatarUrl').attr('src',item);



    var upload = upload.render({
        elem: '#test1'
        , url: '/tp/upload'
        , accept: 'file' //普通文件
        , before: function (obj) {
            obj.preview(function (index, file, result) {
                $('#avatarUrl').attr('src', result);
            });

            element.progress('demo', '0%'); //进度条复位
            layer.msg('上传中', {icon: 16, time: 0});
        }
        , done: function (res) {

            //如果上传失败
            if (res.code > 0) {
                return layer.msg('上传失败');
            }
            //上传成功
            var demoText = $('#demoText');
            demoText.html('<span style="color: #4cae4c;">上传成功</span>');

            var fileupload = $(".image");
            fileupload.attr("value", res.src);
            console.log(fileupload.attr("value"));

        }
        , error: function () {
            //演示失败状态，并实现重传
            var demoText = $('#demoText');
            demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
            demoText.find('.demo-reload').on('click', function () {
                uploadInst.upload();
            });
        }
        //进度条
        , progress: function (n, elem, e) {
            element.progress('demo', n + '%'); //可配合 layui 进度条元素使用
            if (n == 100) {
                layer.msg('上传完毕', {icon: 1});
            }
        }
    });
    $("#qd").on('click',function (res){
        let val = form.val("formfilter");
        console.log(val);
        addactiv(val);
    })
})

function addactiv(d){
    $.ajax({
        type:"post"
        ,url:'/Primary/editz'
        ,data:d
        ,dataType:'json'
        ,success:function(res){

            //关闭弹框
            let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭

            // 刷新父页面的table表格
            parent.refaseUser();
        }
        ,error:function (e){
            console.log("失败");
            console.log(e)
        }
    })
}